package com.lb.jwitter.action;


 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map; 
import org.springframework.beans.factory.annotation.Autowired;
import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; 
import org.springframework.test.context.ContextConfiguration;
import com.opensymphony.xwork2.ActionContext; 
import org.springframework.context.support.ClassPathXmlApplicationContext;
 import com.opensymphony.xwork2.Action; 
 import com.lb.jwitter.service.ConditionReport; 
 import com.lb.jwitter.service.TblQuyenChiTietService;import com.lb.jwitter.service.TblTaiKhoan;import com.lb.jwitter.service.TblQLDTTXABienNhanHoSo;
 import com.lb.jwitter.service.TblQLDTTXABienNhanHoSoService;
 import com.lb.jwitter.service.TblCanBo;
 import com.lb.jwitter.service.TblCanBoService;

import com.lb.jwitter.service.TblQLDTTXAHoSoXetTuyen;
 import com.lb.jwitter.service.TblQLDTTXAHoSoXetTuyenService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXABienNhanHoSoFormAction{
    private int pageSize; 
    public int getPageSize() {
       return pageSize;
 }

    private int page; 
    public int getPage() { return page; }

    private int pages; 
    public int getPages() { return pages; }

    private String dataString; 
    public String getDataString() { return dataString; }

    private Collection<TblQLDTTXABienNhanHoSo> tblQLDTTXABienNhanHoSos; 
    public Collection<TblQLDTTXABienNhanHoSo>  getTblQLDTTXABienNhanHoSos() {
         return tblQLDTTXABienNhanHoSos; 
      } 

    private TblQLDTTXABienNhanHoSoService tblQLDTTXABienNhanHoSoService; 

    private Collection<TblCanBo> tblCanBos; 
    public Collection<TblCanBo>  getTblCanBos(){ 
              return tblCanBos; 
     } 

    private TblCanBoService tblCanBoService; 

    private Collection<TblQLDTTXAHoSoXetTuyen> tblQLDTTXAHoSoXetTuyens; 
    public Collection<TblQLDTTXAHoSoXetTuyen>  getTblQLDTTXAHoSoXetTuyens(){ 
              return tblQLDTTXAHoSoXetTuyens; 
     } 

    private TblQLDTTXAHoSoXetTuyenService tblQLDTTXAHoSoXetTuyenService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; public String execute() throws Exception 
{ 
 try{ 	
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_BienNhanHoSo", "sua")){ 
        return "noprivilege"; 
    }
    tblQLDTTXABienNhanHoSoService = (TblQLDTTXABienNhanHoSoService) context.getBean("tbl_QLDTTXA_BienNhanHoSoClient"); 
         tblCanBoService = (TblCanBoService) context.getBean("tbl_CanBoClient"); 

        tblQLDTTXAHoSoXetTuyenService = (TblQLDTTXAHoSoXetTuyenService) context.getBean("tbl_QLDTTXA_HoSoXetTuyenClient"); 

       if(pageSize == 0){ 
            pageSize = 20; 
        } 
        if(page == 0){ 
            page =1; 
        } 
        tblQLDTTXABienNhanHoSos = tblQLDTTXABienNhanHoSoService.findAlltblQLDTTXABienNhanHoSo(pageSize, page); 
        pages = tblQLDTTXABienNhanHoSoService.counttblQLDTTXABienNhanHoSoByCondition(new ArrayList<ConditionReport>())/pageSize + 1; 
      tblCanBos = tblCanBoService.findAlltblCanBo(0, 0);
      
//      tblQLDTTXAHoSoXetTuyens = tblQLDTTXAHoSoXetTuyenService.findAlltblQLDTTXAHoSoXetTuyen(0, 0);
      
      dataString = ""; 
      dataString += "&tungayNhan="; 
      dataString += "&denngayNhan="; 
      dataString += "&soBienLai="; 
      dataString += "&canBoId=" ; 
      dataString += "&hoSoId=" ; 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi Form tbl_QLDTTXA_BienNhanHoSo Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
